#!/bin/bash

echo "============================================"
echo "构建RuoYi后端Docker镜像"
echo "============================================"
echo ""

# 检查Docker是否运行
if ! docker info > /dev/null 2>&1; then
    echo "[错误] Docker未运行，请先启动Docker服务"
    exit 1
fi

echo "[1/3] 开始构建Docker镜像..."
docker build -t gen-backend:latest .

if [ $? -ne 0 ]; then
    echo "[错误] 镜像构建失败"
    exit 1
fi

echo ""
echo "[2/3] 镜像构建成功！"
echo ""
echo "[3/3] 验证镜像"
docker images | grep gen-backend

echo ""
echo "============================================"
echo "构建完成！"
echo "============================================"
echo ""
echo "使用以下命令启动服务："
echo "docker-compose up -d"
echo ""
echo "或使用 start-docker.sh 脚本启动"
echo ""

